﻿using System;

namespace JQuery.WebKit.WebClient
{
    public partial class JUpdaterControl : JPage
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            JUpdater1.Refresh += new PipelineEventHandler(updatePanel_Submit);
            Page.PageSubmit += new PipelineEventHandler(Page_PageSubmit);
            Page.PageRefresh += new EventHandler(Page_PageRefresh);
            JUpdaterSimple.Refresh += new PipelineEventHandler(updatePanel_Submit);
        }

        void Page_PageRefresh(object sender, EventArgs e)
        {
        }

        void Page_PageSubmit(object sender, PipelineEventArgs e)
        {
            //Thread.Sleep(200);
        }

        void updatePanel_Submit(object sender, PipelineEventArgs e)
        {
           // Thread.Sleep(1000);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            lblServerTime1.Text = DateTime.Now.ToString("hh:mm:ss");
            lblServerTime2.Text = DateTime.Now.ToString("hh:mm:ss");
            lblServerTime3.Text = DateTime.Now.ToString("hh:mm:ss");
            lblServerTime4.Text = DateTime.Now.ToString("hh:mm:ss");
            lblServerTime5.Text = DateTime.Now.ToString("hh:mm:ss");
            lblServerTimeSimple.Text = DateTime.Now.ToString("hh:mm:ss");
        }

        protected string GetID(int index)
        {
            switch (index)
            {
                case 1:
                    return JUpdater1.ClientID;
                case 2:
                    return JUpdater2.ClientID;
                case 3:
                    return JUpdater3.ClientID;
                case 4:
                    return JUpdater4.ClientID;
                case 5:
                    return JUpdater5.ClientID;
                default:
                    return "";
            }
        }

        protected override void OnPreRender(EventArgs e)
        {
            Page.AddJQueryPlugin(JPluginEnum.JQueryStopWatch);
            base.OnPreRender(e);
        }
    }
}